package com.aiti.lulian.service.impl;

import com.aiti.base.core.base.service.iml.BaseSerivceImpl;
import com.aiti.lulian.entity.LuLianOffer;
import com.aiti.lulian.entity.message.OfferMessage;
import com.aiti.lulian.mapper.ILuLianOfferMapper;
import com.aiti.lulian.mapper.OfferMessageMapper;
import com.aiti.lulian.service.IOfferMessageService;
import com.aiti.lulian.vo.LuLianOfferVo;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @Author WongMz
 * @CreateDate 2024-08-07
 */
@Service
public class OfferMessageServiceImpl extends BaseSerivceImpl<OfferMessageMapper, OfferMessage> implements IOfferMessageService {

    @Autowired
    private ILuLianOfferMapper offerMapper;

    @Autowired
    private IOfferMessageService offerMessageService;

    @Override
    public Map<String, Object> queryOfferMessage(String userId) {
        Map<String, Object> map = new HashMap<>();

        LambdaQueryWrapper<OfferMessage> wrapper = new LambdaQueryWrapper<>();
        wrapper.eq(OfferMessage::getSourcingOrderUserId, userId);
        wrapper.eq(OfferMessage::getIsRead, "0");
        wrapper.orderByDesc(OfferMessage::getBaseCreateTime);
        List<OfferMessage> list = offerMessageService.list(wrapper);

        map.put("total", list.size());
        map.put("list", list);

        return map;
    }

    @Override
    public List<LuLianOfferVo> getRegisteredInquiryDataList(Page<LuLianOffer> page, String userId) {
        List<LuLianOfferVo> registeredInquiryDataList = offerMapper.getRegisteredInquiryDataList(page, userId);
        return registeredInquiryDataList;
    }
}